package rendava;
import javax.swing.JPanel;

/**
 * Backend. Where things get passed around.
 * @author Farrell Hayman, Ben Gomm
 * @version 0.1
 */
public class Backend {
	public Parser parser;
	public Renderer renderer;
	public String filePath;
	private JPanel canvas;
	private GUI gui;
	public Backend (String f, JPanel c, GUI gui)
	{
		this.gui = gui;
		filePath = f;
		canvas = c;
		render(parse(filePath));
	}
	/**
	 * Asks Parser to parse a given filepath and returns the tree.
	 * @param filepath File path of the HTML file.
	 * @return completed tree.
	 */
	public Tree parse(String filepath)
	{
		parser = new Parser(filepath);
		return parser.getTree();  
	}
	/**
	 * Asks renderer to render a given tree.
	 * @param tree Tree to render.
	 */
	public void render(Tree tree )
	{
		renderer = new Renderer(tree, canvas, gui);
	}
	/**
	 * Sets the zoom level in the renderer.
	 * @param zoomlevel zoom level to set.
	 */
	public void zoom(float zoomlevel)
	{
		renderer.setZoomLevel(zoomlevel);
	}

}
